#ifndef GANTTCHARTVIEWMODEL_HPP
#define GANTTCHARTVIEWMODEL_HPP

#include <QObject>
#include <QWidget>
#include <QDateTime>
#include <QList>
#include "assembly/model/GanttChartModel.hpp"
#include <QtCharts/QChart>
#include <QtCharts/QValueAxis>
#include <QtCharts/QCategoryAxis>
#include <QTimer>
#include <QGraphicsItem>
#include <QDebug>

class GanttChartViewModel : public QObject {
    Q_OBJECT

public:
    explicit GanttChartViewModel(QObject *parent = nullptr)
        : QObject(parent), model(new GanttChartModel(this)) {
        // 连接 model 的信号到 ViewModel 的信号
        connect(model, &GanttChartModel::startTimeChanged, this, &GanttChartViewModel::startTimeChanged);
        connect(model, &GanttChartModel::endTimeChanged, this, &GanttChartViewModel::endTimeChanged);
        connect(model, &GanttChartModel::durationsChanged, this, &GanttChartViewModel::durationsChanged);
    }


    // 获取开始时间
    QDateTime getStartTime() const {
        return model-> getStartTime();
    }

    // 获取结束时间
    QDateTime getEndTime() const {
        return model-> getEndTime();
    }

    QList<DurationCarrier> getDurations() const {
        return model->getDurations();
    }

signals:
    void startTimeChanged(const QDateTime &newStartTime);
    void endTimeChanged(const QDateTime &newEndTime);
    void durationsChanged(const QList<DurationCarrier> &durations);

private:
    GanttChartModel *model;
};

#endif // GANTTCHARTVIEWMODEL_HPP
